package com.tonysong.oa.yeboa12.config.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * User  Book  ... ---》 R
 * 返回后端的执行结果的共用类
 * @param <T>
 */
@Data
@Accessors(chain = true)
public class R<T> {

    private Integer code;//状态码： 200 404
    private Boolean flag;;//执行结果
    private String message; //消息
    private T data; //数据

    //返回执行成功：增、删、改
//    public static R success(Integer code, Boolean flag, String message){
//        R r=new R();
//        r.setCode(code).setFlag(flag).setMessage(message);
//        return r;
//    }
    public R(){}

    public R(Integer code, String message){
        this.code = code;
        this.message = message;
    }
    public R(Integer code, Boolean flag, T data){
        this.code = code;
        this.flag = flag;
        this.data = data;
    }
    public R(Integer code, Boolean flag, String message){
        this.code = code;
        this.flag = flag;
        this.message = message;
    }
    public R(Integer code, String message, T data){
        this(code, message);
        this.data = data;
    }
    public R(Integer code, Boolean flag, String message, T data){
        this(code, flag, message);
        this.data = data;
    }
}
